#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

struct node{
	int xi;
	int yi;
}ap[5010];

bool cmp(node x,node y){
	return x.yi<y.yi;
}

int main(){
	int n;	int s;	int a;	int b;	int ans = 0;
	cin >> n >> s >> a >> b;
	for(int i = 1; i <= n; i++){
		scanf("%d%d",&ap[i].xi,&ap[i].yi);
	}
	sort(ap,ap+n+1,cmp);
	for(int i = 1;i <= n; i++){
		if(ap[i].xi<=a+b&&ap[i].yi<=s){
			ans++;
			s-=ap[i].yi;
		}
	}
	cout<<ans<<endl;
	return 0;
}